package in.sv.yaazhi.acs.impl;

import in.sv.yaazhi.acs.intf.RagaACS;
import in.sv.yaazhi.dao.RagaVO;
import in.sv.yaazhi.entity.Raga;

import java.util.ArrayList;
import java.util.List;

public class RagaACSImpl extends RagaACS {

	@Override
	public Raga createRaga(RagaVO ragaVO) {

		/** PREPARE */

		Raga raga = new Raga();

		/** EXECUTE */

		raga.setAarohanam(ragaVO.getAarohanam());
		raga.setAvarohanam(ragaVO.getAvarohanam());
		raga.setRagaName(ragaVO.getRagaName());

		getEntityManager().persist(raga);

		/** CONCLUDE */
		return raga;
	}

	@Override
	public Raga updateRaga(RagaVO ragaVO, Raga raga) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Raga deleteRaga(Raga raga) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	@SuppressWarnings(value = "unchecked")
	public List<Raga> searchRaga(RagaVO ragaVO) {

		/** PREPARE */

		List<Raga> ragas = new ArrayList<Raga>();

		/** EXECUTE */

		ragas = getEntityManager().createNamedQuery("searchRaga")
				.setParameter("ragaName", ragaVO.getRagaName()).getResultList();

		/** CONCLUDE */
		return ragas;

	}

}
